<include file="Public:head" title='话题详情' />
<link rel="stylesheet" href="__PUBLIC__/plugins/wangEditor/wangEditor.css" />
<script src="__PUBLIC__/js/other/validate.js"></script>
<script src="__PUBLIC__/plugins/wangEditor/wangEditor.min.js"></script>
<script>
    $(function() {
        $("#form").validate({
            errorPlacement: function(error, element) {
                var error_td = element.parent('td');
                error_td.find('label.error').hide();
                error_td.append(error);
            },
            rules: {
                title: {
                    required: true
                },
                pid: {
                    required: true
                }
            },
            messages: {
                title: {
                    required: "标题不能为空"
                },
                pid: {
                    required: "请选择话题分类"
                }
            }
        });
        // $.getScript("__PUBLIC__/js/plugins/kind2/kindeditor-min.js", function() {
        //     KindEditor.basePath = '__PUBLIC__/js/plugins/kind2/';
        //     KindEditor.create('textarea[id="content"]');
        // });
    })
</script>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
        <include file="Public:left" />
        <div class="main-content">
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li><i class="icon-home home-icon"></i><a href="__APP__/{$Think.MODULE_NAME}">首页</a></li>
                    <li><a href="{:U('Topic/lists')}">话题管理</a></li>
                    <li class="active">话题{$Think.get.id|getPageType}</li>
                </ul>
            </div>
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="row">
                            <div class="col-xs-12">
                                <h3 class="header smaller lighter blue">话题{$Think.get.id|getPageType} </h3>

                                <form action="{:U('Topic/detail_post')}" method="POST" id="form">
                                    <table class="table table_detail">
                                        <tbody>
                                            <tr>
                                                <td class="td_left">话题标题:</td>
                                                <td>
                                                    <input name="title" type="text" class="common_txt"  value="{$detail.name}" autocomplete="off"/>
                                                     <a href="https://www.sucaihuo.com/topic/{$Think.get.id}.html" target="_blank">查看</a>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="td_left">话题分类:</td>
                                                <td>
                                                    <select name="cats" name="cat_id" autocomplete="off">
                                                        <foreach name="cats" item="row">
                                                            <option value="{$row.id}"<if condition="$row.id eq $detail['cat_id']">selected</if> >

                                                            {$row.name}                                                
                                                            </option>
                                                        </foreach>
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="td_left">内容</td>
                                                <td>
                                                    <div id="content"  rows="25" cols="80">{$detail.content}</div>
                                                </td>
                                            </tr>
                                            <textarea id="textcontent" style="display:none;" name="content" style="width:100%; height:200px;"></textarea>
                                            <tr>
                                                <td class="td_left"></td>
                                                <td>
                                                    <input type='hidden' name='id' value='{$Think.get.id}'/>
                                                    <button class="btn btn-info btn-sm" type="submit">
                                                        <i class="icon-ok bigger-110 "></i>
                                                        保 存
                                                    </button>
                                                    <button class="btn btn-sm reset" type="button" onclick="goUrl(-1)">
                                                        <i class="icon-undo bigger-110"></i>
                                                        返 回
                                                    </button>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <include file="Public:setting" />
    </div>
    <script type="text/javascript">
        var E = window.wangEditor
        var editor = new E('#content')
        var $textcontent = $('#textcontent')
        editor.customConfig.zIndex = 100
        editor.customConfig.menus = [
            'head',  // 标题
            'bold',  // 粗体
            'fontSize',  // 字号
            'fontName',  // 字体
            'italic',  // 斜体
            'underline',  // 下划线
            'strikeThrough',  // 删除线
            'foreColor',  // 文字颜色
            'backColor',  // 背景颜色
            'link',  // 插入链接
            'list',  // 列表
            'justify',  // 对齐方式
            'quote',  // 引用
            'emoticon',  // 表情
            'image',  // 插入图片
            'video',  // 插入视频
            'code',  // 插入代码
        ]
        // 配置服务器端地址
        editor.customConfig.uploadImgServer = '/Tian/Topic/topic_img'
        editor.customConfig.uploadImgMaxSize = 1 * 1024 * 1024
        editor.customConfig.onchange = function (html) {
            // 监控变化，同步更新到 textarea
            $textcontent.val(html)
        }
        editor.create();
        $textcontent.val(editor.txt.html())
    </script>
</div>
<include file="Public:foot" />